package com.ruoyi.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.HhSizeMapper;
import com.ruoyi.system.domain.HhSize;
import com.ruoyi.system.service.IHhSizeService;

/**
 * 商品规格Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-06-16
 */
@Service
public class HhSizeServiceImpl implements IHhSizeService 
{
    @Autowired
    private HhSizeMapper hhSizeMapper;

    /**
     * 查询商品规格
     * 
     * @param sizeId 商品规格ID
     * @return 商品规格
     */
    @Override
    public HhSize selectHhSizeById(Long sizeId)
    {
        return hhSizeMapper.selectHhSizeById(sizeId);
    }

    /**
     * 查询商品规格列表
     * 
     * @param hhSize 商品规格
     * @return 商品规格
     */
    @Override
    public List<HhSize> selectHhSizeList(HhSize hhSize)
    {
        return hhSizeMapper.selectHhSizeList(hhSize);
    }

    /**
     * 新增商品规格
     * 
     * @param hhSize 商品规格
     * @return 结果
     */
    @Override
    public int insertHhSize(HhSize hhSize)
    {
        int flag = hhSizeMapper.selecttypeIdAndtypeNameCount(hhSize.getTypeId(),hhSize.getTypeName());
        if (flag<=0){
            return 0;
        }
        return hhSizeMapper.insertHhSize(hhSize);
    }

    /**
     * 修改商品规格
     * 
     * @param hhSize 商品规格
     * @return 结果
     */
    @Override
    public int updateHhSize(HhSize hhSize)
    {
        int flag = hhSizeMapper.selecttypeIdAndtypeNameCount(hhSize.getTypeId(),hhSize.getTypeName());
        if (flag<=0){
            return 0;
        }
        return hhSizeMapper.updateHhSize(hhSize);
    }

    /**
     * 批量删除商品规格
     * 
     * @param sizeIds 需要删除的商品规格ID
     * @return 结果
     */
    @Override
    public int deleteHhSizeByIds(Long[] sizeIds)
    {
        return hhSizeMapper.deleteHhSizeByIds(sizeIds);
    }

    /**
     * 删除商品规格信息
     * 
     * @param sizeId 商品规格ID
     * @return 结果
     */
    @Override
    public int deleteHhSizeById(Long sizeId)
    {
        return hhSizeMapper.deleteHhSizeById(sizeId);
    }
}
